<?php

namespace app\dao\goods;

use app\dao\BaseDao;
use app\model\Tag;

class TagDao extends BaseDao
{
    public function updateById($id,array $updateList)
    {
        $this->getModel()->where('id', '=', $id)->update($updateList);
    }

    public function getPageList($page, $perPage)
    {
        $query = $this->getModel();

        return $this->pagination($query, $page, $perPage);
    }

    public function deleteById($id)
    {
        $this->getModel()->destroy($id);
    }

    public function getById($id)
    {
        return $this->getModel()->find($id);
    }

    public function getAll()
    {
        $query = $this->getModel();
        return [
            'pagination' => ['page' => 1, 'perPage' => -1, 'total' => $query->count()],
            'list'       => $query->select()
        ];
    }

    protected function setModel(): string
    {
        return Tag::class;
    }



}